package services

import (
	"gorm.io/gorm"
	"mygo/app/models"
	"strings"
)

func HandelHdrc(forecast *models.Forecast, time string, db *gorm.DB) {
	timeArr := strings.Split(time, "-")
	year := timeArr[0]
	month := timeArr[1]
	day := timeArr[2]
	timeStr := year + "-" + month + "-" + day
	for i, report := range forecast.Reports {
		if i == 0 {
			var hdrc models.Hdrc
			if db.Where("date = ? AND station = ?", timeStr, "南麂").First(&hdrc).RowsAffected > 0 {
				timeRc := strings.Split(hdrc.TimeRc, ":")
				report.Data[1][2].Value = timeRc[0] + "时" + timeRc[1] + "分"
			}
		}
	}
}
